Two's Complement
Two's complement is a method used to represent negative numbers in binary and to perform binary subtraction efficiently.
Key Concept
When adding two binary numbers, an extra carry bit may appear, which is discarded:
How to Calculate Two's Complement
To compute the two's complement of a binary number:
- Take the 1's complement (invert all bits).
- Add 1 to the result.
Example:
Find two's complement of 1011 (4-bit representation):
Signed Numbers
Signed numbers use the most significant bit (MSB) as a sign bit:
0→ Positive number1→ Negative number
Examples:
(two's complement representation)
Finding Negative of a Number
To find the negative representation of a binary number:
- Take its binary form.
- Apply two's complement.
Example: Represent
Two's complement:
So,
Binary Subtraction Using Two's Complement
Instead of direct subtraction, add the two's complement of the subtrahend to the minuend.
Example:
Step 1: Two's complement of
Step 2: Add to minuend:
Result: